package com.ruoyi.personnel.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.personnel.domain.ECertificationReview;
import com.ruoyi.personnel.service.IECertificationReviewService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 认证审核Controller
 *
 * @author ruoyi
 * @date 2024-11-24
 */
@RestController
@RequestMapping("/certificationReview")
public class ECertificationReviewController extends BaseController
{
    @Autowired
    private IECertificationReviewService eCertificationReviewService;

    /**
     * 查询认证审核列表
     */
    @RequiresPermissions("personnel:certificationReview:list")
    @GetMapping("/list")
    public TableDataInfo list(ECertificationReview eCertificationReview)
    {
        startPage();
        List<ECertificationReview> list = eCertificationReviewService.selectECertificationReviewList(eCertificationReview);
        return getDataTable(list);
    }

    /**
     * 导出认证审核列表
     */
    @RequiresPermissions("personnel:certificationReview:export")
    @Log(title = "认证审核", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ECertificationReview eCertificationReview)
    {
        List<ECertificationReview> list = eCertificationReviewService.selectECertificationReviewList(eCertificationReview);
        ExcelUtil<ECertificationReview> util = new ExcelUtil<ECertificationReview>(ECertificationReview.class);
        util.exportExcel(response, list, "认证审核数据");
    }

    /**
     * 获取认证审核详细信息
     */
//    @RequiresPermissions("personnel:certificationReview:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(eCertificationReviewService.selectECertificationReviewById(id));
    }

    /**
     * 新增认证审核
     */
    @RequiresPermissions("personnel:certificationReview:add")
    @Log(title = "认证审核", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ECertificationReview eCertificationReview)
    {
        return toAjax(eCertificationReviewService.insertECertificationReview(eCertificationReview));
    }

    /**
     * 修改认证审核
     */
    @RequiresPermissions("personnel:certificationReview:edit")
    @Log(title = "认证审核", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ECertificationReview eCertificationReview)
    {
        return toAjax(eCertificationReviewService.updateECertificationReview(eCertificationReview));
    }

    /**
     * 删除认证审核
     */
    @RequiresPermissions("personnel:certificationReview:remove")
    @Log(title = "认证审核", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(eCertificationReviewService.deleteECertificationReviewByIds(ids));
    }

    /*
    * 审核通过
    * */
    @PutMapping("/approvalCertificationReviewStatus/{id}")
    public AjaxResult approvalCertificationReviewStatus(@PathVariable("id") Long id)
    {
    	return toAjax(eCertificationReviewService.approvalCertificationReviewStatus(id));
    }

    /*
    * 审核拒绝
    * */
    @PutMapping("/rejectCertificationReviewStatus")
    public AjaxResult rejectCertificationReviewStatus(@RequestBody ECertificationReview eCertificationReview)
    {
    	return toAjax(eCertificationReviewService.rejectCertificationReviewStatus(eCertificationReview));
    }

    /*
    * 根据认证审核的外键查询快递员认证的详细信息
    * */
    @GetMapping("selectCourierCertificationReviewByPid/{pid}")
    public AjaxResult selectCourierCertificationReviewByPid(@PathVariable("pid") Long pid){
        return success(eCertificationReviewService.selectCourierCertificationReviewByPid(pid));
    }

    /*
    * 根据认证审核的外键查询实名认证的详细信息
    * */
    @GetMapping("selectRealNameCertificationReviewByPid/{pid}")
    public AjaxResult selectRealNameCertificationReviewByPid(@PathVariable("pid") Long pid){
        return success(eCertificationReviewService.selectRealNameCertificationReviewByPid(pid));
    }
}
